/*
 * @lc app=leetcode.cn id=509 lang=javascript
 *
 * [509] 斐波那契数
 */

// @lc code=start
/**
 * @param {number} n
 * @return {number}
 */
var fib = function(n) {
    if (n === 0) {
        return 0
    }
    let arr = [0, 1]
    for (let index = 2; index < n + 1; index++) {
        arr[index] = arr[index - 1] + arr[index - 2]
    }
    return arr[arr.length - 1]
};
// @lc code=end

